package com.test.rxjavademo;

import org.jetbrains.annotations.NotNull;

import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Function;

public class MergeOperatorDemo {

    private static Observer observer = new Observer<Object>() {//Observer观察者，订阅subscribe了被观察者Observable

        @Override
        public void onSubscribe(@NotNull Disposable disposable) {
            System.out.println("1、onSubscribe,首次订阅时会回调:" + disposable);
        }

        @Override
        public void onNext(@NotNull Object o) {
            System.out.println("onNext:" + o);
        }

        @Override
        public void onError(@NotNull Throwable throwable) {
            System.out.println("onError:" + throwable);
        }

        @Override
        public void onComplete() {
            System.out.println("onComplete");
        }
    };






    public static void concatMapTest(){
        //concat  串行
        Observable.concat(
                Observable.just("cc")
                ,Observable.just("bb")
                ,Observable.just("cc")
                ,Observable.just("bb")

        )//两个被观察者，合并为一个被观察者
                .subscribe(observer);
    }




    public static void main(String[] args) {
        concatMapTest();
    }
}
